-- ======================================================================================= -- Modified by Tronex -- 2018/7/2 - ported automatic lists from CoC 1.5 + organized lists -- ======================================================================================= -- axr_debug_tools UI script -- Alundaio --[[ Copyright (C) 2012 Alundaio This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License-]] --]] UI_ICON_EQUIPMENT_WIDTH = 2048 UI_ICON_EQUIPMENT_HEIGHT = 2048 UI_ICON_WIDTH_SCALE = 4.4 id_to_spawn_table = { [1] = "Artefacts", [2] = "Artefacts (Container)", [3] = "Items (Food)", [4] = "Items (Drink)", [5] = "Items (Medical)", [6] = "Items (Device)", [7] = "Items (Tool)", [8] = "Items (Repair)", [9] = "Items (Parts)", [10] = "Items (Misc.)", [11] = "Items (Note)", [12] = "Items (Quest)", [13] = "Items (Upgrades)", [14] = "Helmets", [15] = "Outfits (Attachments)", [16] = "Outfits (Light)", [17] = "Outfits (Medium)", [18] = "Outfits (Heavy)", [19] = "Weapons (Ammo)", [20] = "Weapons (Melee)", [21] = "Weapons (Pistol)", [22] = "Weapons (Shotgun)", [23] = "Weapons (SMG)", [24] = "Weapons (Rifle)", [25] = "Weapons (Sniper)", [26] = "Weapons (Explosive)", [27] = "Weapons (Misc.)", [28] = "NPC (Mutant)", [29] = "NPC (Stalker)", [30] = "Squads (Mutant)", [31] = "Squads (Stalker)", [32] = "Squads (Story ID)", [33] = "Vehicles", [34] = "Anomaly", [35] = "Physic (Misc.)", [36] = "Phantom" } local spawn_table_list function get_spawn_table(name) if (spawn_table_list and spawn_table_list[name]) then return spawn_table_list[name] end spawn_table_list = { ["Artefacts"] = {}, ["Artefacts (Container)"] = {}, ["Items (Food)"] = {}, ["Items (Drink)"] = {}, ["Items (Medical)"] = {}, ["Items (Device)"] = {}, ["Items (Tool)"] = {}, ["Items (Repair)"] = {}, ["Items (Parts)"] = {}, ["Items (Misc.)"] = {}, ["Items (Note)"] = {}, ["Items (Quest)"] = {}, ["Items (Upgrades)"] = {}, ["Helmets"] = {}, ["Outfits (Attachments)"] = {}, ["Outfits (Light)"] = {}, ["Outfits (Medium)"] = {}, ["Outfits (Heavy)"] = {}, ["Weapons (Ammo)"] = {}, ["Weapons (Melee)"] = {}, ["Weapons (Pistol)"] = {}, ["Weapons (Shotgun)"] = {}, ["Weapons (SMG)"] = {}, ["Weapons (Rifle)"] = {}, ["Weapons (Sniper)"] = {}, ["Weapons (Explosive)"] = {}, ["Weapons (Misc.)"] = {}, ["NPC (Mutant)"] = {}, ["NPC (Stalker)"] = {}, ["Squads (Mutant)"] = {}, ["Squads (Stalker)"] = {}, ["Squads (Story ID)"] = {}, ["Vehicles"] = {}, ["Anomaly"] = {}, ["Physic (Misc.)"] = {}, ["Phantom"] = {} } local m_classes = { -- kind ["i_arty_junk"] = "Artefacts", ["i_arty"] = "Artefacts", ["ARTEFACT"] = "Artefacts", ["SCRPTART"] = "Artefacts", ["i_arty_cont"] = "Artefacts (Container)", ["i_mutant_cooked"] = "Items (Food)", ["i_mutant_raw"] = "Items (Food)", ["i_food"] = "Items (Food)", ["II_FOOD"] = "Items (Food)", ["S_FOOD"] = "Items (Food)", ["i_drink"] = "Items (Drink)", ["II_BOTTL"] = "Items (Drink)", ["i_medical"] = "Items (Medical)", ["II_BANDG"] = "Items (Medical)", ["II_MEDKI"] = "Items (Medical)", ["II_ANTIR"] = "Items (Medical)", ["i_device"] = "Items (Device)", ["DET_SIMP"] = "Items (Device)", ["DET_ADVA"] = "Items (Device)", ["DET_ELIT"] = "Items (Device)", ["DET_SCIE"] = "Items (Device)", ["i_kit"] = "Items (Tool)", ["i_tool"] = "Items (Tool)", ["i_repair"] = "Items (Repair)", ["i_part"] = "Items (Parts)", ["i_mutant_part"] = "Items (Misc.)", ["i_misc"] = "Items (Misc.)", ["II_DOC"] = "Items (Misc.)", ["EQ_PATCH"] = "Items (Misc.)", ["II_ATTCH"] = "Items (Misc.)", ["II_BTTCH"] = "Items (Misc.)", ["D_FLALIT"] = "Items (Misc.)", ["S_PDA"] = "Items (Misc.)", ["D_PDA"] = "Items (Misc.)", ["i_letter"] = "Items (Note)", ["i_quest"] = "Items (Quest)", ["i_upgrade"] = "Items (Upgrades)", ["o_helmet"] = "Helmets", ["E_HLMET"] = "Helmets", ["EQU_HLMET"] = "Helmets", ["i_mutant_belt"] = "Outfits (Attachments)", ["i_attach"] = "Outfits (Attachments)", ["i_backpack"] = "Outfits (Attachments)", ["EQ_BAKPK"] = "Outfits (Attachments)", ["o_light"] = "Outfits (Light)", ["E_STLK"] = "Outfits (Medium)", ["EQU_STLK"] = "Outfits (Medium)", ["o_medium"] = "Outfits (Medium)", ["o_sci"] = "Outfits (Medium)", ["o_heavy"] = "Outfits (Heavy)", ["w_ammo"] = "Weapons (Ammo)", ["AMMO"] = "Weapons (Ammo)", ["AMMO_S"] = "Weapons (Ammo)", ["S_OG7B"] = "Weapons (Ammo)", ["S_VOG25"] = "Weapons (Ammo)", ["S_M209"] = "Weapons (Ammo)", ["w_melee"] = "Weapons (Melee)", ["WP_KNIFE"] = "Weapons (Melee)", ["w_pistol"] = "Weapons (Pistol)", ["WP_HPSA"] = "Weapons (Pistol)", ["WP_PM"] = "Weapons (Pistol)", ["WP_USP45"] = "Weapons (Pistol)", ["w_shotgun"] = "Weapons (Shotgun)", ["WP_ASHTG"] = "Weapons (Shotgun)", ["WP_BM16"] = "Weapons (Shotgun)", ["w_smg"] = "Weapons (SMG)", ["w_rifle"] = "Weapons (Rifle)", ["WP_AK74"] = "Weapons (Rifle)", ["WP_GROZA"] = "Weapons (Rifle)", ["WP_LR300"] = "Weapons (Rifle)", ["WP_VAL"] = "Weapons (Rifle)", ["w_sniper"] = "Weapons (Sniper)", ["WP_SVD"] = "Weapons (Sniper)", ["WP_SVU"] = "Weapons (Sniper)", ["w_explosive"] = "Weapons (Explosive)", ["WP_RG6"] = "Weapons (Explosive)", ["WP_RPG7"] = "Weapons (Explosive)", ["G_F1_S"] = "Weapons (Explosive)", ["G_RGD5_S"] = "Weapons (Explosive)", ["G_F1"] = "Weapons (Explosive)", ["G_RGD5"] = "Weapons (Explosive)", ["w_misc"] = "Weapons (Misc.)", ["WP_SCOPE"] = "Weapons (Misc.)", ["WP_SILEN"] = "Weapons (Misc.)", ["WP_GLAUN"] = "Weapons (Misc.)", ["S_WPN_MISC"] = "Weapons (Misc.)", ["WP_BINOC"] = "Weapons (Misc.)", ["II_BOLT"] = "Weapons (Misc.)", ["AI_STL_S"] = "NPC (Stalker)", ["AI_TRD_S"] = "NPC (Stalker)", ["SM_KAR"] = "NPC (Mutant)", ["SM_BLOOD"] = "NPC (Mutant)", ["SM_BOARW"] = "NPC (Mutant)", ["SM_BURER"] = "NPC (Mutant)", ["SM_CAT_S"] = "NPC (Mutant)", ["SM_CHIMS"] = "NPC (Mutant)", ["SM_CONTR"] = "NPC (Mutant)", ["SM_DOG_S"] = "NPC (Mutant)", ["SM_FLESH"] = "NPC (Mutant)", ["SM_IZLOM"] = "NPC (Mutant)", ["SM_GIANT"] = "NPC (Mutant)", ["SM_POLTR"] = "NPC (Mutant)", ["SM_P_DOG"] = "NPC (Mutant)", ["SM_DOG_P"] = "NPC (Mutant)", ["SM_DOG_F"] = "NPC (Mutant)", ["SM_SNORK"] = "NPC (Mutant)", ["SM_TUSHK"] = "NPC (Mutant)", ["SM_ZOMBI"] = "NPC (Mutant)", ["SM_RAT"] = "NPC (Mutant)", ["SM_KARLIK"] = "NPC (Mutant)", ["SM_LURKER"] = "NPC (Mutant)", ["SM_PSYSUCKER"] = "NPC (Mutant)", ["C_HLCP_S"] = "Vehicles", ["C_NIVA"] = "Vehicles", ["SCRPTCAR"] = "Vehicles", ["ON_OFF_S"] = "Squads", ["O_PHYSIC"] = "Physic (Misc.)", ["O_DSTRBL"] = "Physic (Misc.)", ["O_PHYS_S"] = "Physic (Misc.)", ["O_DSTR_S"] = "Physic (Misc.)", ["S_INVBOX"] = "Physic (Misc.)", ["O_INVBOX"] = "Physic (Misc.)", ["S_EXPLO"] = "Physic (Misc.)", ["II_EXPLO"] = "Physic (Misc.)", ["ZS_MBALD"] = "Anomaly", ["ZS_GALAN"] = "Anomaly", ["ZS_MINCE"] = "Anomaly", ["ZS_RADIO"] = "Anomaly", ["ZS_TORRD"] = "Anomaly", ["ZS_NGRAV"] = "Anomaly", ["Z_MBALD"] = "Anomaly", ["Z_RADIO"] = "Anomaly", ["Z_CFIRE"] = "Anomaly", ["Z_NOGRAV"] = "Anomaly", ["Z_TORRID"] = "Anomaly", ["Z_RUSTYH"] = "Anomaly", ["ZS_BFUZZ"] = "Anomaly", ["ZS_AMEBA"] = "Anomaly", ["AI_PHANT"] = "Phantom", } local ltx = ini_file("plugins\\spawner_blacklist.ltx") local sfind = string.find ini_sys:section_for_each(function(section) if (not ltx:line_exist("ignore_sections",section)) and (not sfind(section,"tch_")) and (not sfind(section,"mp_")) and (not sfind(section,"_base")) then local class = ini_sys:r_string_ex(section,"class") local kind = ini_sys:r_string_ex(section,"kind") -- special class name for the sake of correct listing if kind then class = kind end if (class) then local typ = m_classes[class] if (typ) then if (typ == "Squads") then local is_monster = ini_sys:r_string_ex(section,"faction") or "" local story_id = ini_sys:r_string_ex(section,"story_id") or "" if story_id ~= "" then --typ = typ .. " (Story ID)" elseif (sfind(is_monster,"monster")) then typ = typ .. " (Mutant)" elseif (sfind(section,"sim_squad_")) then typ = typ .. " (Stalker)" end elseif (typ == "NPC (Stalker)") or (typ == "NPC (Mutant)") then local character_profile = ini_sys:r_string_ex(section,"character_profile") or "" local story_id = ini_sys:r_string_ex(section,"story_id") or "" local species = ini_sys:r_string_ex(section,"species") or "" if (story_id ~= "") then typ = "na" elseif (species == "human") and (not sfind(character_profile,"sim_default_")) then typ = "na" end elseif (sfind(typ,"Items")) then if (ini_sys:r_bool_ex(section,"quest_item",false) == true) then typ = "Items (Quest)" end elseif (sfind(typ,"Weapons")) and (typ ~= "Weapons (Misc.)") then local parent_section = ini_sys:r_string_ex(section,"parent_section") or section if (parent_section ~= section) then typ = "na" end end local scope = ini_sys:r_string_ex(section,"description") if (scope and scope:find("st_dxr_addon_scope_")) then typ = "Weapons (Misc.)" end if (spawn_table_list[typ]) then spawn_table_list[typ][#spawn_table_list[typ]+1] = section end end end end return false end ) return spawn_table_list[name] end ------------------------------------------------------------ -- List box ------------------------------------------------------------ class "set_list_text" (CUIListBoxItem) function set_list_text:__init(height) super(height) self.sect = self:GetTextItem() self.sect:SetWndRect (Frect():set(0,0,300,22)) self:SetTextColor (GetARGB(255, 216, 186, 140)) self.sect:SetFont (GetFontLetterica18Russian()) self.sect:SetWndSize (vector2():set(400,height)) self.sect:SetEllipsis (true) end ------------------------------------------------------------ -- MAIN DEBUG UI ------------------------------------------------------------ class "debug_ui" (CUIScriptWnd) function debug_ui:__init(owner,binds) super() self.owner = owner self.binds = binds self.txt_console = {} self.tab_list = {} self.console_size = 27 self.icon_scale = 1.0 self:InitControls() self:InitCallBacks() self.tab:SetActiveTab("spawner") self:SendOutput("Alundaio's xrs_debug_tools version 2.5 [Type help for a list of commands]") self.console_relay = false end function debug_ui:__finalize() end function debug_ui:Reinit(level_present) self.level_present = level_present if not (level_present) then self.tab:SetActiveTab("editor") else self.tab:SetActiveTab("spawner") end self:OnTabChange() end function debug_ui:CreateTab(uID) self.tab_list[uID] = true self["dlg_"..uID] = this["debug_ui_"..uID](self,binds) self["dlg_"..uID]:InitControls(0,0, self.xml, self) self["dlg_"..uID]:Show(false) self.dialog:AttachChild(self["dlg_"..uID]) self.xml:InitWindow("tab_size", 0, self["dlg_"..uID]) end function debug_ui:InitControls() self:SetWndRect (Frect():set(0,0,1024,768)) self:Enable (true) local xml = CScriptXmlInit() self.xml = xml xml:ParseFile ("ui_debug_main.xml") xml:InitStatic ("background", self) self.dialog = xml:InitStatic("main_dialog:dialog", self) -- Menu Quit local btn = xml:Init3tButton("main_dialog:btn_quit", self.dialog) self:Register(btn,"btn_quit") -- Teleport Button btn = xml:Init3tButton("main_dialog:btn_tp", self.dialog) self:Register(btn,"btn_tp") -- Display Animation on Hud Button btn = xml:Init3tButton("main_dialog:btn_anim_onHud",self.dialog) self:Register(btn, "btn_hud_anim") -- Console self.console = xml:InitStatic("console",self) self.console_input = xml:InitEditBox("console:input",self) self:Register(self.console_input,"console_input") --self.scroll_v = xml:InitScrollView("console:scroll_v", self.dialog) --self.scroll_v:AddWindow(self.console, true) local offset = vector2() offset.x = 10 offset.y = 10 for i=1,self.console_size do self.txt_console[i] = xml:InitTextWnd("console:ln",self.console) self.txt_console[i]:SetWndPos(offset) offset.y = offset.y + 15 self.txt_console[i]:SetTextColor( GetARGB(255,240, 240, 240)) end self.txt_console[1]:SetTextColor( GetARGB(255,255, 255, 255)) -- Info self.form = xml:InitStatic("main_dialog:form",self.dialog) xml:InitStatic("main_dialog:cap_focus_id", self.dialog) self.txt_focus = xml:InitTextWnd("main_dialog:form:txt_focus", self.form) xml:InitStatic("main_dialog:cap_near_id", self.dialog) self.txt_near = xml:InitTextWnd("main_dialog:form:txt_near", self.form) -- Tabs --self:CreateTab("spawner") --self:CreateTab("editor") --self:CreateTab("object") --self:CreateTab("advanced") -- Dialog Tab self.tab = xml:InitTab("main_dialog:tab", self.dialog) self:Register(self.tab, "tab") end function debug_ui:SetCurrentValues() end function debug_ui:ShowConsole() if not (self.console:IsShown()) then self.console:Show(true) self.console_input:Show(true) end end function debug_ui:HideConsole() if (self.console:IsShown()) then self.console:Show(false) self.console_input:Show(false) end end function debug_ui:Update() CUIScriptWnd.Update(self) end function debug_ui:InitCallBacks() self:AddCallback("tab", ui_events.TAB_CHANGED, self.OnTabChange, self) self:AddCallback("btn_quit", ui_events.BUTTON_CLICKED, self.OnQuit, self) self:AddCallback("btn_tp", ui_events.BUTTON_CLICKED, self.OnBtnTeleport, self) self:AddCallback("btn_spawn", ui_events.BUTTON_CLICKED, self.OnBtnSpawn, self) self:AddCallback("btn_spawn_squad", ui_events.BUTTON_CLICKED, self.OnBtnSpawnSquad, self) self:AddCallback("btn_focus", ui_events.BUTTON_CLICKED, self.OnBtnFocus, self) self:AddCallback("btn_execute_string", ui_events.BUTTON_CLICKED, self.OnBtnExecuteString, self) --self:AddCallback("btn_switch_distance", ui_events.BUTTON_CLICKED, self.OnBtnSwitchDistance, self) self:AddCallback("btn_find", ui_events.BUTTON_CLICKED, self.OnBtnFindNearest, self) self:AddCallback("btn_set", ui_events.BUTTON_CLICKED, self.OnBtnSetLogic, self) self:AddCallback("btn_revert", ui_events.BUTTON_CLICKED, self.OnBtnRevertLogic, self) self:AddCallback("btn_reload", ui_events.BUTTON_CLICKED, self.OnBtnReloadIni, self) self:AddCallback("console_input", ui_events.EDIT_TEXT_COMMIT, self.OnConsoleInput, self) --- Spawner Tab self:AddCallback("list_sections", ui_events.LIST_ITEM_SELECT, self.OnSelectSectionList, self) self:AddCallback("list_window", ui_events.WINDOW_LBUTTON_DB_CLICK, self.OnButton_create_clicked, self) --self:AddCallback("btn_create", ui_events.BUTTON_CLICKED, self.OnButton_create_clicked, self) -- Icon Editor self:AddCallback("editor_list_sections", ui_events.LIST_ITEM_SELECT, self.OnSelectEditorSectionList, self) self:AddCallback("editor_list_window", ui_events.WINDOW_LBUTTON_DB_CLICK, self.OnEditorTriggerSectionSelection, self) self:AddCallback("fld_icon_x", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconX, self) self:AddCallback("fld_icon_y", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconY, self) self:AddCallback("fld_icon_width", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconW, self) self:AddCallback("fld_icon_height", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconH, self) self:AddCallback("fld_addon_offset_x", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconOffX, self) self:AddCallback("fld_addon_offset_y", ui_events.EDIT_TEXT_COMMIT, self.OnEditIconOffY, self) self:AddCallback("editor_list_addon", ui_events.LIST_ITEM_SELECT, self.OnEditorTriggerAddonSectionSelection, self) self:AddCallback("btn_editor_save", ui_events.BUTTON_CLICKED, self.OnEditorSave, self) -- -- level jump tab self:AddCallback("list_levels_window", ui_events.WINDOW_LBUTTON_DB_CLICK, self.JumpLevel, self) self:AddCallback("list",ui_events.LIST_ITEM_CLICKED,self.OnListItemClicked,self) self:AddCallback("list", ui_events.WINDOW_LBUTTON_DB_CLICK, self.OnStartAnim,self) self:AddCallback("btn_hud_anim", ui_events.BUTTON_CLICKED, self.OnStartHudAnim,self) end function debug_ui:OnConsoleInput() local txt = self.console_input:GetText() if (txt == "") then return end local wrd = "" local _strt, _end = string.find(txt,".%S+") if (_strt and _end) then wrd = string.sub(txt,_strt, _end) wrd = string.lower(wrd) else return "For usage type echo help" end if not (debug_cmd_list.command_exists(wrd)) then self:SendOutput("Command %s cannot be found. Type help for a list of commands.",wrd) return end -- Grab rest of str local args = string.sub(txt,string.len(wrd)+1) -- Trim args = string.gsub(args, "^%s*(.-)%s*$", "%1") -- Perform execute string on $vars local p ={} local var_list = debug_cmd_list.get_var_list() for s in string.gmatch(args,"$(.-)%$") do s = string.gsub(s, "^%s*(.-)%s*$", "%1") if (s and s ~= "" and var_list[s]) then table.insert(p,s) else local ls,err = loadstring("return function() local val = " .. s .."; return val; end") local func = ls and ls() or err local val = func and type(func) == "function" and func() table.insert(p,val) end end -- replace all %s with returned vals local i = 0 local function sr(a) i = i + 1 if ( type(p[i] ~= "userdata") )then if ( var_list[p[i]] and type(var_list[p[i]] ~= "userdata") ) then return tostring(var_list[p[i]]) end return tostring(p[i]) end return "" end local output = string.gsub(args,"%%s",sr) -- Remove all $exe_strs output = string.gsub(output,"$(.-)%$","") -- Send Output self:SendOutput(debug_cmd_list.command_give(wrd,output,self,p)) end function debug_ui:OnBtnTeleport() local pos = xrs_debug_tools.LastCameraPos if (pos) then local car = db.actor:get_attached_vehicle() if (car) then db.actor:detach_vehicle() end db.actor:set_actor_position(pos) self:OnQuit() end end function debug_ui:OnBtnSpawn() local txt = self.fld_spawn:GetText() if (txt ~= "") then self:spawn_section(txt) end end function debug_ui:OnBtnSpawnSquad() local sec = self.fld_spawn_squad:GetText() local smrt = self.fld_spawn_smart:GetText() if (sec ~= "") then self:spawn_squad(sec,smrt) end end function debug_ui:SendOutput(txt,...) if not (txt) or (txt == "") then return end local i = 0 local out = txt local p = {...} if (#p > 0) then local function sr(a) i = i + 1 return tostring(p[i]) end out = string.gsub(txt,"%%s",sr) end for n=1,#self.txt_console-1,1 do local s = self.txt_console[n+1]:GetText() self.txt_console[n]:SetText(s) end self.txt_console[#self.txt_console]:SetText(out) if (self.console_relay) then printf("Debug Console: %s",out) end end function debug_ui:SendOutputList(list,start,finish) if not (list and not is_empty(list)) then return end local count = 1 local n = 1 local size = #self.txt_console for k,v in pairs(list) do if (start and count >= start) then if (n < (finish or size)) then self:SendOutput(tostring(v)) n = n + 1 else self:SendOutput(tostring(v)) return end else count = count + 1 end end for i=n,finish do self:SendOutput(" ") end end function debug_ui:OnBtnFocus() local txt = self.fld_focus:GetText() if (txt ~= "") then xrs_debug_tools.set_debug_npc(tonumber(txt)) self.txt_focus:SetText(txt) else xrs_debug_tools.set_debug_npc() self.txt_focus:SetText("") end end function debug_ui:OnBtnExecuteString() local txt = self.fld_execute_string:GetText() if (txt ~= "") then assert(loadstring(txt))() end end function debug_ui:OnBtnSwitchDistance() local txt = self.fld_switch_distance:GetText() if (txt ~= "") then local a = alife() local old = a:switch_distance() local amt = tonumber(txt) --utils_data.debug_write("%s %s ",old,amt) a:switch_distance(amt) self:SendOutput("Switch Distance changed from %s to %s.",old,amt) end end function debug_ui:OnBtnFindNearest() local txt = self.fld_find:GetText() self:FindNearest(txt) end function debug_ui:OnBtnSetLogic() local section = self.fld_section:GetText() if (section == "") then return end local id = self.fld_id:GetText() id = id and tonumber(id) local scheme = utils_data.get_scheme_by_section(section) local logic = self.fld_logic:GetText() local ini_filename = self.fld_filename:GetText() if (id and scheme and section and ini_filename) then local obj = db.storage[id] and db.storage[id].object or level.object_by_id(id) if (obj) then xr_logic.set_new_scheme_and_logic(obj,scheme,section,logic,nil,ini_filename) self:SendOutput("New scheme and logic set for %s.",obj:name()) end end end function debug_ui:OnBtnRevertLogic() local id = self.fld_id:GetText() id = id and tonumber(id) if (id) then local obj = db.storage[id] and db.storage[id].object or level.object_by_id(id) if (obj) then xr_logic.restore_scheme_and_logic(obj) self:SendOutput("Reverted scheme and logic for %s.",obj:name()) end end end function debug_ui:OnBtnReloadIni() local txt = self.fld_reload:GetText() if (txt and txt ~= "") then local st = db.storage[tonumber(txt)] if (st) then st.ini = nil st.ini, st.ini_filename = xr_logic.get_customdata_or_ini_file(st.object, st.ini_filename) xr_logic.switch_to_section(st.object,nil,nil) self:SendOutput("INI reload performed on %s.",st.object:name()) end end end function debug_ui:OnQuit() self:HideDialog() if (self.level_present) then exec_console_cmd("main_menu off") else if not (self.owner:IsShown()) then self.owner:ShowDialog(true) self.owner:Show(true) end end end function debug_ui:OnTabChange() for k,v in pairs(self.tab_list) do self["dlg_"..k]:Show(false) end local ids = self.tab:GetActiveId() if (ids == "editor" or not self.level_present) then if not (self.dlg_editor) then self:CreateTab("editor") end self.dlg_editor:Show(true) if (self.ui_icon_equipment) then self:HideConsole() self.ui_icon_equipment:Show(true) self.ui_icon_equipment_back:Show(true) self.icon_square:Show(true) end return else if not (self.level_present) then return end if (self.ui_icon_equipment) then self.ui_icon_equipment:Show(false) self.icon_square:Show(false) self.ui_icon_equipment_back:Show(false) self:ShowConsole() end end if not (self["dlg_"..ids]) then self:CreateTab(ids) end self["dlg_"..ids]:Show(true) end function debug_ui:OnKeyboard(dik, keyboard_action) CUIScriptWnd.OnKeyboard(self,dik,keyboard_action) if keyboard_action == ui_events.WINDOW_KEY_RELEASED then local keybinds = self.binds or {} if dik == DIK_keys.DIK_ESCAPE then self:OnQuit() -- Tronex test elseif dik == DIK_keys.DIK_HOME then printf("~Home key pressed") local name = self.sections_list:GetText() local spawntbl = name and get_spawn_table(name) if (spawntbl) then printf("~Spawn everything from list (%s)", name) local sim = alife() local sfind = string.find table.sort(spawntbl) for i = 1, #spawntbl do if (ini_sys:section_exist(spawntbl[i])) and (not sfind(spawntbl[i], "_eot")) and (not sfind(spawntbl[i], "_acog")) and (not sfind(spawntbl[i], "_ac10632")) and (not sfind(spawntbl[i], "_1p29")) and (not sfind(spawntbl[i], "_kobra")) and (not sfind(spawntbl[i], "_ps01")) and (not sfind(spawntbl[i], "_c-more")) and (not sfind(spawntbl[i], "_ac11090")) and (ini_sys:r_float_ex(spawntbl[i], "cost")) then sim:create(spawntbl[i], db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id(), AC_ID) printf("-spawned section [%s]",spawntbl[i]) end end end elseif (keybinds["keybind_teleport_to_cam"] and dik == DIK_keys["DIK_"..keybinds["keybind_teleport_to_cam"]]) then self:OnBtnTeleport() elseif (keybinds["debug_ui_nearest_stalker"] and dik == DIK_keys["DIK_"..keybinds["debug_ui_nearest_stalker"]]) then self:FindNearest("clsid.script_stalker") elseif (keybinds["debug_ui_spawn_position"] and dik == DIK_keys["DIK_"..keybinds["debug_ui_spawn_position"]]) then self.spawn_pos = db.actor:position() self.spawn_lvid = db.actor:level_vertex_id() self.spawn_gvid = db.actor:game_vertex_id() self:SendOutput("Set current spawning position to actor location. [To set to default type spawn reset]") end end return true end function debug_ui:spawn_section(text) if not ini_sys:section_exist(text) then return false end local pos, lvid, gvid if (self.spawn_pos) then pos = self.spawn_pos lvid = self.spawn_lvid gvid = self.spawn_gvid else pos = db.actor:position() lvid = db.actor:level_vertex_id() gvid = db.actor:game_vertex_id() end local obj = alife_create(text,pos,lvid,gvid) --printf("Spawned Object %s as ID: %s",obj:name(),obj.id) self:SendOutput("Object %s created as ID %s.",obj:name(),obj.id) return true end function debug_ui:spawn_squad(section,smart_name) if not ini_sys:section_exist(section) then self:SendOutput("UISpawner: Section %s does not exist in system INI.",section) return false end printf("section=%s smart_name=%s", section, smart_name) local sim = alife() local smart = smart_name and smart_name ~= "" and SIMBOARD.smarts_by_names[smart_name] local squad if (smart) then squad = sim:create(section,smart.position,smart.m_level_vertex_id,smart.m_game_vertex_id) if (squad) then squad:create_npc(smart) end else squad = sim:create(section,db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id()) if (squad) then squad:create_npc(nil,db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id()) end end if (squad) then for k in squad:squad_members() do local se_obj = k.object or k.id and sim:object(k.id) if (se_obj) then SIMBOARD:setup_squad_and_group(se_obj) end end self:SendOutput("UISpawner: Squad %s created as ID %s at %s.",squad:name(),squad.id,smart and smart_name or "actor") return true end self:SendOutput("UISpawner: failed to create %s",section) return false end function debug_ui:FindNearest(txt) if (txt and txt ~= "") then local near,dist if (string.find(txt,"clsid")) then local cls = string.sub(txt,7) if (clsid[cls]) then near,dist = utils_obj.nearest_object(clsid[cls],true) end else near,dist = utils_obj.nearest_object(txt,true) end if (near) then local id = near.id local st = near:clsid() == clsid.script_stalker and db.storage[id] if (st) then local scheme = st.active_scheme local section = st.active_section local logic = st.section_logic local ini_filename = st.ini_filename if not (self.dlg_object) then self:CreateTab("object") end if (self.fld_id) then self.fld_id:SetText(id or "") self.fld_section:SetText(section or "") self.fld_logic:SetText(logic or "") self.fld_filename:SetText(ini_filename or "") if (self.fld_focus) then self.fld_focus:SetText(id or "") end if (self.fld_reload) then self.fld_reload:SetText(id or "") end end self.txt_near:SetText(id) end self:SendOutput("%s with ID %s found with distance %s",near:name(),id,dist) else --printf("Could not find object matching name") self.txt_near:SetText("Not Found") self:SendOutput("Object with name not found.") end end end function debug_ui:FillList(name) if not (name) then self:SendOutput("UISpawner: No spawn table could be created for %s",name) return end self.spawn_list:Clear() local spawntbl = get_spawn_table(name) if not (spawntbl) then self:SendOutput("UISpawner: No spawn table could be created for %s",name) return end local is_squad = string.find(name,"Squad") local cant_spawn_actor = string.find(name,"NPC") or string.find(name,"Physic") local is_veh = string.find(name,"Vehicles") local is_anom = string.find(name,"Anomaly") local is_phantom = string.find(name,"Phantom") if (is_squad) then -- self.smarts_list:Show(true) else -- self.smarts_list:Show(false) end table.sort(spawntbl) for i = 1, #spawntbl do if (ini_sys:section_exist(spawntbl[i])) then local _itm = set_list_text(22) --local name = ui_item.get_sec_name(sections[i]) --_itm.name:SetText(name) _itm.sect:SetText(spawntbl[i]) if (is_squad) then _itm.no_id = true _itm.squad = true _itm.spawn_at_look = true elseif (cant_spawn_actor) then _itm.no_id = true _itm.spawn_at_look = true elseif (is_veh) then _itm.no_id = true _itm.spawn_at_look = true elseif (is_anom) then _itm.no_id = true _itm.spawn_at_look = true _itm.is_anom = true elseif (is_phantom) then _itm.no_id = true _itm.spawn_at_look = true _itm.use_level_spawn = true end self.spawn_list:AddExistingItem(_itm) end end end function debug_ui:FillEditorList(name) self.editor_icon:SetTextureRect(Frect():set(0,0,0,0)) if not (name) then self:SendOutput("UIEditor: No spawn table could be created for %s",name) return end self.editor_spawn_list:Clear() local spawntbl = get_spawn_table(name) if not (spawntbl) then self:SendOutput("UIEditor: No spawn table could be created for %s",name) return end table.sort(spawntbl) for i = 1, #spawntbl do if (ini_sys:section_exist(spawntbl[i])) then local _itm = set_list_text(22) _itm.sect:SetText(spawntbl[i]) self.editor_spawn_list:AddExistingItem(_itm) end end end function debug_ui:FillLevelList() local s,t = {},{} local levels = utils_data.collect_section(game_ini(),"level_maps_single") for i,level in pairs(levels) do local ts = game.translate_string(level) table.insert(s,ts) t[ts] = level end table.sort(s) for i,lvl_name in ipairs(s) do local _itm = set_list_text(22) _itm.sect:SetText(lvl_name) _itm.name = t[lvl_name] self.levels_list:AddExistingItem(_itm) end end function debug_ui:JumpLevel() local item item = self.levels_list:GetSelectedItem() if not(item) then self:SendOutput("UIAdvanced: No level was selected in the list.") return end self:OnQuit() _G.JumpToLevel(item.name) end function debug_ui:OnSelectSectionList() self:FillList(self.sections_list:GetText()) end function debug_ui:OnSelectEditorSectionList() self:FillEditorList(self.editor_sections_list:GetText()) end function debug_ui:OnButton_create_clicked() if self.spawn_list:GetSize() == 0 then self:SendOutput("UISpawner: List is empty.") return end local item item = self.spawn_list:GetSelectedItem() if not(item) then self:SendOutput("UISpawner: No item section was selected in the list.") return end local section = item.sect:GetText() if (item.squad) then local smart = self.smarts_list:GetText() self:spawn_squad(section,smart) return end local pos, lvid, gvid if (item.spawn_at_look) then gvid = db.actor:game_vertex_id() local r = level.get_target_dist and level.get_target_dist() or 3 pos = vector():set(db.actor:position()) pos:add(device().cam_dir:mul(r)) pos = vector():set(pos.x,db.actor:position().y,pos.z) lvid = level.vertex_id(pos) elseif (self.spawn_pos) then pos = self.spawn_pos lvid = self.spawn_lvid gvid = self.spawn_gvid else pos = db.actor:position() lvid = db.actor:level_vertex_id() gvid = db.actor:game_vertex_id() end if (item.use_level_spawn) then if (level.spawn_item) then level.spawn_item(section,pos,lvid,65535,false) self:SendOutput("UISpawner: Spawned") end return end local id = not item.no_id and self.check_to_actor:GetCheck() and 0 local se_obj if (id) then se_obj = alife_create(section, db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id(), AC_ID) else se_obj = alife_create(section, pos, lvid, gvid) end if not (se_obj) then self:SendOutput("UISpawner: Failure to create item with alife create method %s",section) return end if (item.is_anom) then local data = utils_stpk.get_object_data(se_obj) if (data) then data.object_flags = 31 --data.artefact_spawn_count = 1 data.restrictor_type = 0 data.shapes = {} data.shapes[1] = {} data.shapes[1].shtype = 0 data.shapes[1].offset = VEC_ZERO data.shapes[1].radius = 10 utils_stpk.set_object_data(data,se_obj) end end self:SendOutput("UISpawner: Spawned %s on %s as id %s",se_obj:name(),id == AC_ID and "Actor" or "level",se_obj.id) end function debug_ui:OnEditorTriggerAddonSectionSelection() local item item = self.editor_spawn_list:GetSelectedItem() if not(item) then self:SendOutput("UIEditor: No item section was selected in the list.") return end local section = item.sect:GetText() if not (ini_sys:section_exist(section)) then self:SendOutput(strformat("UIEditor: Section %s does not exist",section)) return end local addon_sec = self.addon_list:GetText() if not (addon_sec and addon_sec ~= "" and addon_sec ~= "Select Attachment" and ini_sys:section_exist(addon_sec) and self._addons[addon_sec]) then self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0)) self.fld_addon_offset_x:SetText("") self.fld_addon_offset_y:SetText("") return end local _type = self._addons[addon_sec] local scope_sec = self._scopes[addon_sec] or section if (self._addons[addon_sec] == "scope" and self._scopes[addon_sec]) then addon_sec = ini_sys:r_string_ex(self._scopes[addon_sec],self._addons[addon_sec].."_name") or addon_sec end local addon_inv_grid_width = ini_sys:r_float_ex(addon_sec,"inv_grid_width") or 0 local addon_inv_grid_height = ini_sys:r_float_ex(addon_sec,"inv_grid_height") or 0 local addon_inv_grid_x = ini_sys:r_float_ex(addon_sec,"inv_grid_x") or 0 local addon_inv_grid_y = ini_sys:r_float_ex(addon_sec,"inv_grid_y") or 0 local addon_x1 = addon_inv_grid_x*50 local addon_y1 = addon_inv_grid_y*50 local addon_w = addon_inv_grid_width*50 local addon_h = addon_inv_grid_height*50 local addon_x2 = addon_x1 + addon_w local addon_y2 = addon_y1 + addon_h local offset_x = ini_sys:r_float_ex(scope_sec,_type.."_x") or 0 local offset_y = ini_sys:r_float_ex(scope_sec,_type.."_y") or 0 local scale = (ini_sys:r_float_ex(scope_sec,_type.."_scale") or 1) * self.icon_scale self.editor_icon_addon:InitTexture("ui\\ui_icon_equipment") self.editor_icon_addon:SetTextureRect(Frect():set(addon_x1,addon_y1,addon_x2,addon_y2)) self.editor_icon_addon:SetWndSize(vector2():set(addon_w*scale,addon_h*scale)) pos = self.editor_icon:GetWndPos() self.editor_icon_addon:SetWndPos(vector2():set(pos.x+offset_x*scale,pos.y+offset_y*scale)) self.fld_addon_offset_x:SetText(tostring(offset_x)) self.fld_addon_offset_y:SetText(tostring(offset_y)) end function debug_ui:OnEditorTriggerSectionSelection() self.editor_icon:SetTextureRect(Frect():set(0,0,0,0)) self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0)) if self.editor_spawn_list:GetSize() == 0 then self:SendOutput("UIEditor: List is empty.") return end local item item = self.editor_spawn_list:GetSelectedItem() if not(item) then self:SendOutput("UIEditor: No item section was selected in the list.") return end local section = item.sect:GetText() if not (ini_sys:section_exist(section)) then self:SendOutput(strformat("UIEditor: Section %s does not exist",section)) return end self._addons = {} -- temp self._scopes = {} -- temp self.addon_list:ClearList() self.addon_list:AddItem("Select Attachment",0) -- default self.addon_list:SetText("Select Attachment") ----------------------- local inv_grid_width = ini_sys:r_float_ex(section,"inv_grid_width") or 0 local inv_grid_height = ini_sys:r_float_ex(section,"inv_grid_height") or 0 local inv_grid_x = ini_sys:r_float_ex(section,"inv_grid_x") or 0 local inv_grid_y = ini_sys:r_float_ex(section,"inv_grid_y") or 0 self.icon_scale = 1.0 - (inv_grid_width * 0.052) self.editor_old_x = inv_grid_x self.editor_old_y = inv_grid_y self.editor_old_w = inv_grid_width self.editor_old_h = inv_grid_height local x1 = inv_grid_x*50 local y1 = inv_grid_y*50 local w = inv_grid_width*50 local h = inv_grid_height*50 local x2 = x1 + w local y2 = y1 + h self.editor_icon:InitTexture("ui\\ui_icon_equipment") self.editor_icon:SetTextureRect(Frect():set(x1,y1,x2,y2)) self.editor_icon:SetWndSize(vector2():set(w*self.icon_scale,h*self.icon_scale)) local pos = self.editor_icon_back:GetWndPos() self.editor_icon:SetWndPos(vector2():set(pos.x+(self.editor_icon_back:GetWidth()/2)-(w*self.icon_scale)/2,pos.y+(self.editor_icon_back:GetHeight()/2)-(h*self.icon_scale)/2)) self.fld_icon_x:SetText(tostring(inv_grid_x)) self.fld_icon_y:SetText(tostring(inv_grid_y)) self.fld_icon_width:SetText(tostring(inv_grid_width)) self.fld_icon_height:SetText(tostring(inv_grid_height)) pos = self.ui_icon_equipment:GetWndPos() self.icon_square:SetWndPos(vector2():set( pos.x+x1/UI_ICON_WIDTH_SCALE , pos.y+y1/3 )) self.icon_square:SetWndSize(vector2():set(w/UI_ICON_WIDTH_SCALE,h/3)) self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0)) self.fld_addon_offset_x:SetText("") self.fld_addon_offset_y:SetText("") local idx = 1 -- attachments local silencer = ini_sys:r_string_ex(section,"silencer_name") local grenade_launcher = ini_sys:r_string_ex(section,"grenade_launcher_name") if (silencer and ini_sys:section_exist(silencer)) then self.addon_list:AddItem(silencer,idx) self._addons[silencer] = "silencer" idx = idx + 1 end if (grenade_launcher and ini_sys:section_exist(grenade_launcher)) then self.addon_list:AddItem(grenade_launcher,idx) self._addons[grenade_launcher] = "grenade_launcher" idx = idx + 1 end local scopes = parse_list(ini_sys,section,"scopes_sect") if (scopes and #scopes > 0) then for k,v in pairs(scopes) do self.addon_list:AddItem(v,idx) self._scopes[v] = v self._addons[v] = "scope" idx = idx + 1 end end local cnt = 1 local layer = ini_sys:r_string_ex(section,"1icon_layer") while (layer ~= nil) do self.addon_list:AddItem(layer,idx) idx = idx + 1 self.addon_list:SetText(layer) self._addons[layer] = cnt.."icon_layer" cnt = cnt + 1 layer = ini_sys:r_string_ex(section,cnt.."icon_layer") if (layer == nil) then self:OnEditorTriggerAddonSectionSelection() end end end function debug_ui:OnEditIconX() local v = tonumber(self.fld_icon_x:GetText()) if (v and v ~= self.editor_old_x) then self.need_save_x = true end self:OnEditIcon() end function debug_ui:OnEditIconY() local v = tonumber(self.fld_icon_y:GetText()) if (v and v ~= self.editor_old_y) then self.need_save_y = true end self:OnEditIcon() end function debug_ui:OnEditIconW() local v = tonumber(self.fld_icon_width:GetText()) if (v and v ~= self.editor_old_w) then self.need_save_w = true end self:OnEditIcon() end function debug_ui:OnEditIconH() local v = tonumber(self.fld_icon_height:GetText()) if (v and v ~= self.editor_old_h) then self.need_save_h = true end self:OnEditIcon() end function debug_ui:OnEditIconOffX() local v = tonumber(self.fld_addon_offset_x:GetText()) if (v and v ~= self.editor_old_offset_x) then self.need_save_offset_x = true end self:OnEditIcon() end function debug_ui:OnEditIconOffY() local v = tonumber(self.fld_addon_offset_y:GetText()) if (v and v ~= self.editor_old_offset_y) then self.need_save_offset_y = true end self:OnEditIcon() end function debug_ui:OnEditIcon() local x1 = tonumber(self.fld_icon_x:GetText()) local y1 = x1 and tonumber(self.fld_icon_y:GetText()) local w = y1 and tonumber(self.fld_icon_width:GetText()) local h = w and tonumber(self.fld_icon_height:GetText()) if not (x1 and y1 and w and h) then return end local scale = 0.75 x1 = x1*50 y1 = y1*50 w = w*50 h = h*50 local x2 = x1 + w local y2 = y1 + h --self.editor_icon:InitTexture("ui\\ui_icon_equipment") self.editor_icon:SetTextureRect(Frect():set(x1,y1,x2,y2)) self.editor_icon:SetWndSize(vector2():set(w*scale,h*scale)) local pos = self.ui_icon_equipment:GetWndPos() self.icon_square:SetWndPos(vector2():set( pos.x+x1/UI_ICON_WIDTH_SCALE , pos.y+y1/3 )) self.icon_square:SetWndSize(vector2():set(w/UI_ICON_WIDTH_SCALE,h/3)) local name = self.addon_list:GetText() if not (name and name ~= "" and name ~= "Select Attachment") then self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0)) self.fld_addon_offset_x:SetText("") self.fld_addon_offset_y:SetText("") return end local offset_x = tonumber(self.fld_addon_offset_x:GetText()) local offset_y = offset_x and tonumber(self.fld_addon_offset_y:GetText()) if not (offset_y) then self.editor_icon_addon:SetTextureRect(Frect():set(0,0,0,0)) self.fld_addon_offset_x:SetText("") self.fld_addon_offset_y:SetText("") return end pos = self.editor_icon:GetWndPos() self.editor_icon_addon:SetWndPos(vector2():set(pos.x+offset_x*scale,pos.y+offset_y*scale)) end function debug_ui:OnEditorSave() if not (self.need_save_x or self.need_save_y or self.need_save_w or self.need_save_h or self.need_save_offset_x or self.need_save_offset_y) then return end local x1 = tonumber(self.fld_icon_x:GetText()) local y1 = x1 and tonumber(self.fld_icon_y:GetText()) local w = y1 and tonumber(self.fld_icon_width:GetText()) local h = w and tonumber(self.fld_icon_height:GetText()) if not (h) then return end local offset_x = tonumber(self.fld_addon_offset_x:GetText()) local offset_y = offset_x and tonumber(self.fld_addon_offset_y:GetText()) local item = self.editor_spawn_list:GetSelectedItem() if not(item) then self:SendOutput("UIEditorSave: No item section was selected in the list.") return end local section = item.sect:GetText() if not (ini_sys:section_exist(section)) then self:SendOutput(strformat("UIEditorSave: Section %s does not exist",section)) return end local addon_sec = self.addon_list:GetText() if (addon_sec == nil or addon_sec == "" or addon_sec == "Select Attachment") then addon_sec = nil self.need_save_offset_x = nil self.need_save_offset_y = nil end local search_sec = self._addons[addon_sec] == "scope" and self._scopes[addon_sec] or section local function file_exists(path) return io.open(path) ~= nil end local function on_execute(path,filename,quit) local fullpath = path.."\\"..filename local ltx = io.open(fullpath,"rb") if (ltx) then local data = ltx:read("*all") ltx:close() if (data) then if (string.find(data,"["..section.."]",nil,true)) then ltx = utils_data.cfg_file(fullpath) if (ltx) then if (self.need_save_x) then ltx:SetValue(section,"inv_grid_x",x1) end if (self.need_save_y) then ltx:SetValue(section,"inv_grid_y",y1) end if (self.need_save_w) then ltx:SetValue(section,"inv_grid_width",w) end if (self.need_save_h) then ltx:SetValue(section,"inv_grid_height",h) end ltx:SaveExt() else printf("make sure your gamedata is unpacked from db!") end end if (self.need_save_offset_x or self.need_save_offset_y) and (string.find(data,"["..search_sec.."]",nil,true)) then ltx = utils_data.cfg_file(fullpath) if (ltx) then if (self.need_save_offset_x) then ltx:SetValue(search_sec,self._addons[addon_sec].."_x",offset_x) end if (self.need_save_offset_y) then ltx:SetValue(search_sec,self._addons[addon_sec].."_y",offset_y) end ltx:SaveExt() else printf("make sure your gamedata is unpacked from db!") end end end end end local sp = getFS():update_path('$game_config$', '') sp = string.sub(sp,0,string.len(sp)-1) lua_ext.recurse_subdirectories_and_execute(sp,{"ltx"},on_execute) reload_ini_sys() self.need_save_x = nil self.need_save_y = nil self.need_save_w = nil self.need_save_h = nil self.need_save_offset_x = nil self.need_save_offset_y = nil end -- ANIMATIONS UI function debug_ui:FillAnim() local anim_tbl = {} local function fill_tbl(path,filename) local s,e = path:find("anims") path = string.sub(path,e+2,string.len(path)) if path ~= "" then path = path.."\\" end table.insert(anim_tbl,{path = path,fn = filename}) end local sp = getFS():update_path('$game_anims$', '') sp = string.sub(sp,0,string.len(sp)-1) lua_ext.recurse_subdirectories_and_execute(sp,{"ppe","anm"},fill_tbl) ------- self.anims_list:Clear() for i=1, #anim_tbl do local _itm = set_list_text(22) _itm.sect:SetText(anim_tbl[i].fn) _itm.name = anim_tbl[i].path..anim_tbl[i].fn self.anims_list:AddExistingItem(_itm) end end function debug_ui:OnListItemClicked() local item = self.anims_list:GetSize() > 0 and self.anims_list:GetSelectedItem() if not (item) then return end local idx = self.anims_list:GetSelectedIndex() printf("index = %s table size = %s", idx, self.anims_list:GetSize()) if not item then printf("missing list item") end end function debug_ui:OnStartAnim() local item = self.anims_list:GetSize() > 0 and self.anims_list:GetSelectedItem() if not (item) then return end local name = item.name printf("name %s",name) if name:find(".anm") then level.add_cam_effector(name, 8010, false, "") elseif name:find(".ppe") then level.add_pp_effector(name, 999, false) end self:OnQuit() end function debug_ui:OnStartHudAnim() self:OnQuit() anim_ui(get_hud()):ShowDialog(true) end -- SPAWNER UI class "debug_ui_spawner" (CUIWindow) function debug_ui_spawner:__init(owner, binds) super() self.owner = owner end function debug_ui_spawner:__finalize() end function debug_ui_spawner:InitControls(x, y, xml, owner) self:SetWndPos(vector2():set(x-50,y)) self:SetWndSize(vector2():set(800,416)) self:SetAutoDelete(true) owner.sections_list = xml:InitComboBox("tab_spawner:list_sections", self) owner.sections_list:ClearList() owner.sections_list:SetAutoDelete(true) for i=1,#id_to_spawn_table do owner.sections_list:AddItem(id_to_spawn_table[i],i-1) end owner:Register(owner.sections_list, "list_sections") owner.spawn_list_frame = xml:InitFrame("tab_spawner:list_frame",self) owner.spawn_list = xml:InitListBox("tab_spawner:list",self) owner.spawn_list:ShowSelectedItem(true) owner:Register(owner.spawn_list, "list_window") owner.check_to_actor = xml:InitCheck("tab_spawner:check_own_to_actor",self) owner.check_to_actor:SetCheck(true) --local ctrl = xml:Init3tButton("tab_spawner:btn_create",self) --owner:Register(ctrl, "btn_create") owner.smarts_list = xml:InitComboBox("tab_spawner:list_smarts", self) owner.smarts_list:ClearList() owner.smarts_list:SetAutoDelete(true) local sim = alife() local actor_level = sim:level_name(game_graph():vertex(sim:actor().m_game_vertex_id):level_id()) local board = SIMBOARD local smrts = {} for id,t in pairs(board.smarts) do if (t.smrt and t.smrt.online) then smrts[#smrts+1] = t.smrt:name() end end table.sort(smrts) for i=1,#smrts do owner.smarts_list:AddItem(smrts[i],i) end owner.smarts_list:SetText("Squad to Smart") --owner.smarts_list:Show(false) owner.smarts_list_cap = xml:InitStatic("tab_spawner:cap_smarts", self) --owner:Register(owner.smarts_list, "list_smarts") -- Set defaults owner.sections_list:SetText(owner.sections_list:GetTextOf(0)) owner:FillList(owner.sections_list:GetTextOf(0)) ------------------------- manual input xml:InitStatic("tab_spawner:cap_spawn", self) owner.fld_spawn = xml:InitEditBox("tab_spawner:fld_spawn", self) btn = xml:Init3tButton("tab_spawner:btn_spawn",self) owner:Register(btn, "btn_spawn") xml:InitStatic("tab_spawner:cap_spawn_squad", self) owner.fld_spawn_squad = xml:InitEditBox("tab_spawner:fld_spawn_squad", self) xml:InitStatic("tab_spawner:cap_spawn_smart", self) owner.fld_spawn_smart = xml:InitEditBox("tab_spawner:fld_spawn_smart", self) btn = xml:Init3tButton("tab_spawner:btn_spawn_squad",self) owner:Register(btn, "btn_spawn_squad") end -- HUD UI class "debug_ui_hud" (CUIWindow) function debug_ui_hud:__init(owner, binds) super() self.owner = owner end function debug_ui_hud:__finalize() end function debug_ui_hud:InitControls(x, y, xml, owner) self:SetWndPos(vector2():set(x,y)) self:SetWndSize(vector2():set(800,416)) self:SetAutoDelete(true) xml:InitStatic("tab_hud:cap_focus", self) owner.fld_focus = xml:InitEditBox("tab_hud:fld_focus", self) local btn = xml:Init3tButton("tab_hud:btn_focus",self) owner:Register(btn, "btn_focus") end -- object UI class "debug_ui_object" (CUIWindow) function debug_ui_object:__init(owner, binds) super() self.owner = owner end function debug_ui_object:__finalize() end function debug_ui_object:InitControls(x, y, xml, owner) self:SetWndPos(vector2():set(x,y)) self:SetWndSize(vector2():set(800,416)) self:SetAutoDelete(true) xml:InitStatic("tab_object:cap_find", self) owner.fld_find = xml:InitEditBox("tab_object:fld_find", self) local btn btn = xml:Init3tButton("tab_object:btn_find",self) owner:Register(btn, "btn_find") xml:InitStatic("tab_object:cap_id", self) owner.fld_id = xml:InitEditBox("tab_object:fld_id", self) xml:InitStatic("tab_object:cap_section", self) owner.fld_section = xml:InitEditBox("tab_object:fld_section", self) xml:InitStatic("tab_object:cap_logic", self) owner.fld_logic = xml:InitEditBox("tab_object:fld_logic", self) xml:InitStatic("tab_object:cap_filename", self) owner.fld_filename = xml:InitEditBox("tab_object:fld_filename", self) btn = xml:Init3tButton("tab_object:btn_set",self) owner:Register(btn, "btn_set") btn = xml:Init3tButton("tab_object:btn_revert",self) owner:Register(btn, "btn_revert") xml:InitStatic("tab_object:cap_reload", self) owner.fld_reload = xml:InitEditBox("tab_object:fld_reload", self) btn = xml:Init3tButton("tab_object:btn_reload",self) owner:Register(btn, "btn_reload") end -- ADVANCED UI class "debug_ui_advanced" (CUIWindow) function debug_ui_advanced:__init(owner, binds) super() self.owner = owner end function debug_ui_advanced:__finalize() end function debug_ui_advanced:InitControls(x, y, xml, owner) self:SetWndPos(vector2():set(x,y)) self:SetWndSize(vector2():set(800,416)) self:SetAutoDelete(true) xml:InitStatic("tab_advanced:cap_execute_string", self) owner.fld_execute_string = xml:InitEditBox("tab_advanced:fld_execute_string", self) local btn = xml:Init3tButton("tab_advanced:btn_execute_string",self) owner:Register(btn, "btn_execute_string") xml:InitStatic("tab_advanced:cap_jump_level", self) owner.levels_list_frame = xml:InitFrame("tab_advanced:list_frame",self) owner.levels_list = xml:InitListBox("tab_advanced:list",self) owner.levels_list:ShowSelectedItem(true) owner:Register(owner.levels_list, "list_levels_window") owner:FillLevelList() ---------------------------------------------------------------------------------- xml:InitStatic("tab_advanced:cap_anim", self) owner.anims_list = xml:InitFrame("tab_advanced:anim_frame",self) owner.anims_list = xml:InitListBox("tab_advanced:anim_list",self) owner.anims_list:ShowSelectedItem(true) owner:Register(owner.anims_list, "list") --owner:FillAnim() --TODO: find the reason why this lag the fuck out of the game end -- ICON EDITOR class "debug_ui_editor" (CUIWindow) function debug_ui_editor:__init(owner, binds) super() self.owner = owner end function debug_ui_editor:__finalize() end function debug_ui_editor:InitControls(x, y, xml, owner) self:SetWndPos(vector2():set(x-50,y)) self:SetWndSize(vector2():set(800,416)) self:SetAutoDelete(true) owner.editor_sections_list = xml:InitComboBox("tab_editor:list_sections", self) owner.editor_sections_list:ClearList() owner.editor_sections_list:SetAutoDelete(true) local invalid_ids = {[6] = true , [7] = true, [9] = true, [10] = true, [11] = true} for i=1,#id_to_spawn_table do if not (invalid_ids[i]) then owner.editor_sections_list:AddItem(id_to_spawn_table[i],i-1) end end owner:Register(owner.editor_sections_list, "editor_list_sections") owner.editor_spawn_list_frame = xml:InitFrame("tab_editor:list_frame",self) owner.editor_spawn_list = xml:InitListBox("tab_editor:list",self) owner.editor_spawn_list:ShowSelectedItem(true) owner:Register(owner.editor_spawn_list, "editor_list_window") owner.editor_icon_back = xml:InitStatic("tab_editor:icon_back",self) owner.editor_icon = xml:InitStatic("tab_editor:icon",self) -- Set defaults owner.editor_sections_list:SetText(owner.editor_sections_list:GetTextOf(0)) owner:FillEditorList(owner.editor_sections_list:GetTextOf(0)) ------- xml:InitStatic("tab_editor:cap_w", self) owner.fld_icon_width = xml:InitEditBox("tab_editor:fld_w", self) owner:Register(owner.fld_icon_width,"fld_icon_width") xml:InitStatic("tab_editor:cap_h", self) owner.fld_icon_height = xml:InitEditBox("tab_editor:fld_h", self) owner:Register(owner.fld_icon_height,"fld_icon_height") xml:InitStatic("tab_editor:cap_x", self) owner.fld_icon_x = xml:InitEditBox("tab_editor:fld_x", self) owner:Register(owner.fld_icon_x,"fld_icon_x") xml:InitStatic("tab_editor:cap_y", self) owner.fld_icon_y = xml:InitEditBox("tab_editor:fld_y", self) owner:Register(owner.fld_icon_y,"fld_icon_y") owner.ui_icon_equipment_back = xml:InitFrame("ui_icon_equipment_back",owner) owner.ui_icon_equipment = xml:InitStatic("ui_icon_equipment",owner) owner.ui_icon_equipment:InitTexture("ui\\ui_icon_equipment") owner.ui_icon_equipment:SetWndSize(vector2():set(UI_ICON_EQUIPMENT_WIDTH/UI_ICON_WIDTH_SCALE,UI_ICON_EQUIPMENT_HEIGHT/3)) owner.ui_icon_equipment_back:SetWndSize(vector2():set(UI_ICON_EQUIPMENT_WIDTH/UI_ICON_WIDTH_SCALE+25,UI_ICON_EQUIPMENT_HEIGHT/3+20)) owner.icon_square = xml:InitFrame("square",owner) xml:InitStatic("tab_editor:cap_addon_x", self) owner.fld_addon_offset_x = xml:InitEditBox("tab_editor:fld_addon_x", self) owner:Register(owner.fld_addon_offset_x,"fld_addon_offset_x") xml:InitStatic("tab_editor:cap_addon_y", self) owner.fld_addon_offset_y = xml:InitEditBox("tab_editor:fld_addon_y", self) owner:Register(owner.fld_addon_offset_y,"fld_addon_offset_y") owner.addon_list = xml:InitComboBox("tab_editor:list_addon", self) owner.addon_list:AddItem("dummy",0) owner:Register(owner.addon_list, "editor_list_addon") owner.editor_icon_addon = xml:InitStatic("tab_editor:icon_addon",self) local btn = xml:Init3tButton("tab_editor:btn_save",self) owner:Register(btn, "btn_editor_save") end ---------------------------------------------------- Attach Offsets local _attached local _last_section class "debug_ui_attach" (CUIScriptWnd) function debug_ui_attach:__init(owner, binds) super() self:SetWndRect (Frect():set(0,0,1024,768)) self:Enable (true) local xml = CScriptXmlInit() self.xml = xml xml:ParseFile ("ui_debug_main.xml") self:SetAutoDelete(true) self.owner = owner self.need_save = {} local ctrl = CUIWindow() ctrl:SetAutoDelete(true) self.xml:InitWindow("wnd_attach_editor:file_item:main",0,ctrl) self.form = self.xml:InitStatic("wnd_attach_editor:form",self) self.xml:InitFrame("wnd_attach_editor:form:list_frame",self.form) ctrl = self.xml:Init3tButton("wnd_attach_editor:form:btn_attach",self.form) self:Register(ctrl, "button_attach_npc") self:AddCallback("button_attach_npc", ui_events.BUTTON_CLICKED, self.OnAttach, self) --[[ ctrl = self.xml:Init3tButton("wnd_attach_editor:form:btn_save",self.form) self:Register(ctrl, "button_attach_save") self:AddCallback("button_attach_save", ui_events.BUTTON_CLICKED, self.OnAttachSave, self) --]] xml:InitStatic("wnd_attach_editor:form:cap_pos", self.form) xml:InitStatic("wnd_attach_editor:form:cap_angle", self.form) self.flds = {"x","y","z","rot_x","rot_y","rot_z"} for i=1,#self.flds do xml:InitStatic("wnd_attach_editor:form:cap_"..self.flds[i], self.form) self["fld_attach_"..self.flds[i]] = xml:InitEditBox("wnd_attach_editor:form:fld_"..self.flds[i], self.form) self:Register(self["fld_attach_"..self.flds[i]],"fld_attach_"..self.flds[i]) self:AddCallback("fld_attach_"..self.flds[i], ui_events.EDIT_TEXT_COMMIT, self["On_fld_attach_"..self.flds[i]], self) end self.attachable = xml:InitComboBox("wnd_attach_editor:form:list_attach", self.form) self:Register(self.attachable, "attach_list") self:AddCallback("attach_list", ui_events.LIST_ITEM_SELECT, self.OnAttachListSelect,self) self.attachable:ClearList() local t = parse_list(ini_sys,"stalker","attachable_items") if (#t > 0) then for i=1,#t do if (ini_sys:section_exist(t[i])) then self.attachable:AddItem(t[i],i-1) end end end -- TODO: -- NOT IMPLEMENTED FULLY YET --[[ self.weapons = xml:InitComboBox("wnd_attach_editor:form:list_weapons", self.form) self:Register(self.weapons, "weapon_list") self:AddCallback("weapon_list", ui_events.LIST_ITEM_SELECT, self.OnWeaponListSelect,self) local valid_ids = {13,14,15} -- Weapon spawn tables only for n=1,#valid_ids do local slist = get_spawn_table(id_to_spawn_table[ valid_ids[n] ]) if (slist) then local cnt = 0 for i=1,#slist do if (ini_sys:section_exist(slist[i])) then self.weapons:AddItem(slist[i],cnt) cnt = cnt + 1 end end end end --]] self.anim_states = xml:InitComboBox("wnd_attach_editor:form:list_states", self.form) self:Register(self.anim_states, "state_list") self:AddCallback("state_list", ui_events.LIST_ITEM_SELECT, self.OnStateListSelect,self) self.anim_states:SetAutoDelete(true) t = iempty_table(t) for state,_ in pairs(state_lib.states) do table.insert(t,state) end table.sort(t) for i=1,#t do self.anim_states:AddItem(t[i],i-1) end end function debug_ui_attach:__finalize() end function debug_ui_attach:OnAttachListSelect() self._last = "attach" for i=1,#self.flds do self.need_save[self.flds[i]] = nil end local section = self.attachable:GetText() if not (section and ini_sys:section_exist(section)) then return end local pos = parse_list(ini_sys,section,"attach_position_offset") local angle = parse_list(ini_sys,section,"attach_angle_offset") if not (#pos > 0) then return end for i=1,#pos do if (self["fld_attach_"..self.flds[i]]) then self["fld_attach_"..self.flds[i]]:SetText(pos[i]) end end if not (#angle > 0) then return end for i=1,#angle do if (self["fld_attach_"..self.flds[i+3]]) then self["fld_attach_"..self.flds[i+3]]:SetText(angle[i]) end end end function debug_ui_attach:OnStateListSelect() local state = self.anim_states:GetText() if not (state and state ~= "") then return end local npc = xrs_debug_tools.get_debug_npc() if not (npc and npc:id() ~= 0) then return end db.storage[npc:id()].debug_state = state state_mgr.set_state(npc, state,nil, nil, nil, { fast_set = true }) end function debug_ui_attach:OnWeaponListSelect() self._last = "weapon" for i=1,#self.flds do self.need_save[self.flds[i]] = nil end local section = self.weapons:GetText() if not (section and ini_sys:section_exist(section)) then return end local pos = parse_list(ini_sys,section,"position") local angle = parse_list(ini_sys,section,"orientation") if not (#pos > 0) then return end for i=1,#pos do if (self["fld_attach_"..self.flds[i]]) then self["fld_attach_"..self.flds[i]]:SetText(pos[i]) end end if not (#angle > 0) then return end for i=1,#angle do if (self["fld_attach_"..self.flds[i+3]]) then self["fld_attach_"..self.flds[i+3]]:SetText(angle[i]) end end end function debug_ui_attach:OnAttachSave(section) local need_save local fld local vals = {} for i=1,#self.flds do fld = self["fld_attach_"..self.flds[i]] if not (fld) then return end if not (tonumber(fld:GetText())) then return end if (self.need_save[self.flds[i]] == true) then need_save = true end vals[self.flds[i]] = tonumber(fld:GetText()) end if not (need_save) then return end local function file_exists(path) return io.open(path) ~= nil end local function on_execute(path,filename,quit) local fullpath = path.."\\"..filename local ltx = io.open(fullpath,"rb") if (ltx) then local data = ltx:read("*all") ltx:close() if (data) then if (string.find(data,"["..section.."]",nil,true)) then ltx = utils_data.cfg_file(fullpath) if (ltx) then if (self._last == "attach") then if (self.need_save.x or self.need_save.y or self.need_save.z) then ltx:SetValue(section,"attach_position_offset",vals.x .. ", " .. vals.y .. ", " .. vals.z) end if (self.need_save.rot_x or self.need_save.rot_y or self.need_save.rot_z) then ltx:SetValue(section,"attach_angle_offset",vals.rot_x .. ", " .. vals.rot_y .. ", " .. vals.rot_z) end elseif (self._last == "weapon") then if (self.need_save.x or self.need_save.y or self.need_save.z) then ltx:SetValue(section,"position",vals.x .. ", " .. vals.y .. ", " .. vals.z) end if (self.need_save.rot_x or self.need_save.rot_y or self.need_save.rot_z) then ltx:SetValue(section,"orientation",vals.rot_x .. ", " .. vals.rot_y .. ", " .. vals.rot_z) end end ltx:SaveExt() return end end end end end local sp = getFS():update_path('$game_config$', '') sp = string.sub(sp,0,string.len(sp)-1) lua_ext.recurse_subdirectories_and_execute(sp,{"ltx"},on_execute) reload_ini_sys() end function debug_ui_attach:On_fld_attach_x() self:OnEditAttach("x") end function debug_ui_attach:On_fld_attach_y() self:OnEditAttach("y") end function debug_ui_attach:On_fld_attach_z() self:OnEditAttach("z") end function debug_ui_attach:On_fld_attach_rot_x() self:OnEditAttach("rot_x") end function debug_ui_attach:On_fld_attach_rot_y() self:OnEditAttach("rot_y") end function debug_ui_attach:On_fld_attach_rot_z() self:OnEditAttach("rot_z") end function debug_ui_attach:OnEditAttach(fld) if not (_attached) then return end local section = self._last == "attach" and self.attachable:GetText() or self._last == "weapon" and self.weapons:GetText() or nil if not (section and ini_sys:section_exist(section)) then return end local itm = level.object_by_id(_attached) if not (itm) then return end if not (section == itm:section()) then printe("!ERROR: ui_debug_main.debug_ui_attach : section in combo box is not same section as item! itm=%s selected=%s",itm:section(),section) return end self.need_save[fld] = true self:OnAttachSave(section) itm:attachable_item_load_attach(section) end function debug_ui_attach:OnKeyboard(dik, keyboard_action) CUIScriptWnd.OnKeyboard(self,dik,keyboard_action) if keyboard_action == ui_events.WINDOW_KEY_RELEASED then local keybinds = self.binds or {} if (dik == DIK_keys.DIK_ESCAPE) then self:OnQuit() end end return true end local function delayed_attach(id) local itm = id and level.object_by_id(id) if (itm) then itm:enable_attachable_item(true) _attached = itm:id() return true end return false end function debug_ui_attach:OnAttach() local npc = xrs_debug_tools.get_debug_npc() if not (npc and npc:id() ~= 0) then return printf("debug_ui_attach: no npc found") end local section = self._last == "attach" and self.attachable:GetText() or self._last == "weapon" and self.weapons:GetText() or nil if not (section and ini_sys:section_exist(section)) then return end if (_last_section ~= section) then _last_section = section if (_attached) then local itm = level.object_by_id(_attached) if (itm) then itm:enable_attachable_item(false) end _attached = nil end end local itm = npc:object(section) if not (itm) then local se_itm = alife_create(section,npc:position(),npc:level_vertex_id(),npc:game_vertex_id(),npc:id()) if (se_itm) then CreateTimeEvent(se_itm.id,"delayed_attach",1,delayed_attach,se_itm.id) end else if (_attached) then itm:enable_attachable_item(false) end _attached = itm:id() CreateTimeEvent(itm:id(),"delayed_attach",1,delayed_attach,itm:id()) end end function debug_ui_attach:OnQuit() self:HideDialog() end ------------------------------------------------------------------------------------ class "anim_ui" (CUIScriptWnd) function anim_ui:__init() super() self:InitControls() self:InitCallBacks() end function anim_ui:__finalize() end function anim_ui:Update() CUIScriptWnd.Update(self) end function anim_ui:InitCallBacks() self:AddCallback("list", ui_events.WINDOW_LBUTTON_DB_CLICK, self.OnStartAnim,self) end function anim_ui:InitControls() self:SetWndRect (Frect():set(0,0,1024,768)) self:Enable (true) local xml = CScriptXmlInit() xml:ParseFile ("ui_debug_main.xml") self:SetWndPos(vector2():set(884,0)) self:SetWndSize(vector2():set(140,768)) self.anims_list = xml:InitFrame("anim_frame",self) self.anims_list = xml:InitListBox("anim_list",self) self.anims_list:ShowSelectedItem(true) self:Register(self.anims_list, "list") self:FillAnim() end function anim_ui:FillAnim() local anim_tbl = {} local function fill_tbl(path,filename) local s,e = path:find("anims") path = string.sub(path,e+2,string.len(path)) if path ~= "" then path = path.."\\" end table.insert(anim_tbl,{path = path,fn = filename}) end local sp = getFS():update_path('$game_anims$', '') sp = string.sub(sp,0,string.len(sp)-1) lua_ext.recurse_subdirectories_and_execute(sp,{"ppe","anm"},fill_tbl) ------- self.anims_list:Clear() for i=1, #anim_tbl do local _itm = set_list_text(22) _itm.sect:SetText(anim_tbl[i].fn) _itm.name = anim_tbl[i].path..anim_tbl[i].fn self.anims_list:AddExistingItem(_itm) end end function anim_ui:OnStartAnim() local item = self.anims_list:GetSelectedItem() local name = item.name printf("name %s",name) if name:find(".anm") then level.add_cam_effector(name, 8010, false, "") elseif name:find(".ppe") then level.add_pp_effector(name, 999, false) end end function anim_ui:OnKeyboard(dik, keyboard_action) CUIScriptWnd.OnKeyboard(self,dik,keyboard_action) if keyboard_action == ui_events.WINDOW_KEY_RELEASED then local keybinds = self.binds or {} if (dik == DIK_keys.DIK_ESCAPE) then self:OnQuit() end end return true end function anim_ui:OnQuit() self:HideDialog() end